/*
 * IconPrueba.java
 *
 * Created on 2 de mayo de 2006, 23:40
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package fmap.gui;

import fmap.gui.actionListener.ListenerJFrameIcons;
import fmap.utils.FormUtils;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 *
 * @author javi
 */
public class JFrameIcons extends JFrame
{
    JButton[] aButton;
    String type;
    
    /** Creates a new instance of IconPrueba */
    public JFrameIcons ( String _type)
    {
        type = _type;
        ListenerJFrameIcons listener = new ListenerJFrameIcons ( this );
        
        getContentPane ().setLayout (new java.awt.FlowLayout ());
        
        if( type.equals ("mapF") )
        {
            aButton = new JButton[4];
            
            for( int i=0; i<4; i++)
            {
                int j = i+1;
                aButton[i] = new JButton (new ImageIcon ( getClass ().getResource ("/fmap/img/"+type+"/"+j+".png") ));
                aButton[i].setBorder (null);
                aButton[i].setBorder (javax.swing.BorderFactory.createEmptyBorder (5, 5, 5, 5));
                aButton[i].setName ("/fmap/img/"+type+"/"+j+".png");
                
                aButton[i].addActionListener ( listener );
                
                this.getContentPane ().add ( aButton[i] );
                
            }
        }
        else if( type.equals ("mapFPanelRight") )
        {
            aButton = new JButton[4];
            
            String type2 = "mapF";
            
            for( int i=0; i<4; i++)
            {
                int j = i+1;
                aButton[i] = new JButton (new ImageIcon ( getClass ().getResource ("/fmap/img/"+type2+"/"+j+".png") ));
                aButton[i].setBorder (null);
                aButton[i].setBorder (javax.swing.BorderFactory.createEmptyBorder (5, 5, 5, 5));
                aButton[i].setName ("/fmap/img/"+type2+"/"+j+".png");
                
                aButton[i].addActionListener ( listener );
                
                this.getContentPane ().add ( aButton[i] );
                
            }
        }

        else
        {
            
            aButton = new JButton[21];
            
            for( int i=0; i<21; i++)
            {
                int j = i+1;
                aButton[i] = new JButton (new ImageIcon ( getClass ().getResource ("/fmap/img/"+type+"/"+j+".png") ));
                aButton[i].setBorder (null);
                aButton[i].setBorder (javax.swing.BorderFactory.createEmptyBorder (5, 5, 5, 5));
                aButton[i].setName ("/fmap/img/"+type+"/"+j+".png");
                
                aButton[i].addActionListener ( listener );
                
                this.getContentPane ().add ( aButton[i] );
                
            }
        }
        
        
        this.setPreferredSize (new Dimension (200,240));
        setResizable (false);
        setDefaultCloseOperation (javax.swing.WindowConstants.HIDE_ON_CLOSE);
        setTitle ("Elige Icono");
        setAlwaysOnTop (true);
        pack ();
        // Centramos el formulario
        FormUtils.centra (this);
        setVisible (true);
        
    }

    public String getType()
    {
        return type;
    }
}
